import {
  defineConfig
} from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import Components from 'unplugin-vue-components/vite';
import {
  viteMockServe
} from 'vite-plugin-mock'


import {
  VantResolver
} from 'unplugin-vue-components/resolvers';
import pxtovw from 'postcss-px-to-viewport'
const loder_pxtovw = pxtovw({
  //这里是设计稿宽度 自己修改
  viewportWidth: 750,
  viewportUnit: 'vw'
})

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),
    viteMockServe({
      supportTs: false,
      logger: false,
      mockPath: "./mock/"
    }),
    Components({
      resolvers: [VantResolver()],
    })
  ],
  css: {
    postcss: {
      plugins: [loder_pxtovw]
    }
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://120.53.31.103:84/api/app',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
    }
  },
  resolve: {
    // 配置路径别名
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
})